package chances.epg.data.taglib.page;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import chances.epg.commons.utils.JSONUtils;
import chances.epg.data.PageBean;

public class PageInfo {
	@JsonIgnore
	private PageBean pageBean;
	private String prevUri;
	private String nextUri;
	
	public PageInfo(int pageSize){
		this.pageBean = new PageBean(pageSize);
	}
	
	public PageInfo(int curPage,int pageSize){
		this.pageBean = new PageBean(pageSize);
		pageBean.setCurrentPage(curPage);
	}
	
	public int getPageNo() {
		return this.pageBean.getCurrentPage();
	}
	
	public int getPageIndex() {
		return this.pageBean.getCurrentPage();
	}
	@JsonProperty("pageCount")
	public int getPageCount() {
		return this.pageBean.getPageCount();
	}
	@JsonProperty("recordCount")
	public int getRecordCount() {
		return this.pageBean.getRecordCount();
	}
	
	public PageBean getPageBean() {
		return this.pageBean;
	}

	public String getPrevUri() {
		return prevUri;
	}

	public void setPrevUri(String prevUri) {
		this.prevUri = prevUri;
	}

	public String getNextUri() {
		return nextUri;
	}

	public void setNextUri(String nextUri) {
		this.nextUri = nextUri;
	}
	
	@JsonIgnore
	public String getJson(){
		return JSONUtils.fromObject(this);
	}
}
